package com.yufubao.api.controller.applet.discounts;

import com.yufubao.framework.annotation.SystemLog;
import com.yufubao.framework.result.PageUtils;
import com.yufubao.framework.result.ResponseResult;
import com.yufubao.model.dto.applet.discounts.SkuDiscountsEtcDto;
import com.yufubao.model.pojo.applet.discounts.SkuFullReductionEntity;
import com.yufubao.service.service.applet.discounts.SkuFullReductionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;





/**
 * 商品满减信息
 *
 * @author zhangzhan
 * @email 52194440@qq.com
 * @date 2024-08-29 16:54:10
 */
@Api("商品满减信息")
@RestController
@RequestMapping("/applet/skufullreduction")
public class SkuFullReductionController {
    @Autowired
    private SkuFullReductionService skuFullReductionService;


    /**
     * 保存商品满减、打折信息
     */
    @RequestMapping(value = "/saveSkuDiscountsEtc",method = RequestMethod.POST)
    //@RequiresPermissions("gulimallcoupon:skufullreduction:list")
    @SystemLog(info = "保存商品满减、打折信息")
    @ApiOperation(value = "保存商品满减、打折信息")
    public ResponseResult saveSkuDiscountsEtc(@RequestBody List<SkuDiscountsEtcDto> skuDiscountsEts){
        skuFullReductionService.saveSkuDiscountsEtc(skuDiscountsEts);
        return ResponseResult.ok();
    }

    /**
     * 列表
     */
    @RequestMapping(value = "/list",method = RequestMethod.POST)
    @ApiOperation(value = "列表")
    @SystemLog(info = "商品满减信息列表")
    public ResponseResult list(@RequestBody Map<String, Object> params){
        PageUtils page = skuFullReductionService.queryPage(params);

        return ResponseResult.okResultPage("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping(value = "/info/{id}",method = RequestMethod.GET)
    @ApiOperation(value = "信息")
    @SystemLog(info = "商品满减信息信息")
    public ResponseResult info(@PathVariable("id") Long id){
		SkuFullReductionEntity skuFullReduction = skuFullReductionService.getById(id);

        return ResponseResult.okResultPage("SkuFullReduction", skuFullReduction);
    }

    /**
     * 保存
     */
    @RequestMapping(value = "/save",method = RequestMethod.POST)
    @ApiOperation(value = "保存")
    @SystemLog(info = "商品满减信息保存")
    public ResponseResult save(@RequestBody SkuFullReductionEntity skuFullReduction){
		skuFullReductionService.save(skuFullReduction);

        return ResponseResult.ok();
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update",method = RequestMethod.PUT)
    @ApiOperation(value = "修改")
    @SystemLog(info = "商品满减信息修改")
    public ResponseResult update(@RequestBody SkuFullReductionEntity skuFullReduction){
		skuFullReductionService.updateById(skuFullReduction);

        return ResponseResult.ok();
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete",method = RequestMethod.DELETE)
    @ApiOperation(value = "删除")
    @SystemLog(info = "商品满减信息删除")
    public ResponseResult delete(@RequestBody Long[] ids){
		skuFullReductionService.removeByIds(Arrays.asList(ids));

        return ResponseResult.ok();
    }

}
